package com.example.qihuibao.utils

import android.app.Activity
import android.content.Intent
import java.lang.reflect.Method


object RxDevicesTool {

    //设备硬件编码
    fun getDeviceSN(): String? {
        var serial: String? = null
        try {
            val c = Class.forName("android.os.SystemProperties")
            val get: Method = c.getMethod("get", String::class.java)
            serial = get.invoke(c, "ro.serialno") as String?
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return serial
    }

    fun navigation(activity: Activity, isShow: Boolean) {
        if (isShow) {
            val intent1 = Intent()
            intent1.action = "com.android.systemui.statusbar.phone.statusopen"
            activity.sendBroadcast(intent1)
            val intent2 = Intent()
            intent2.action = "com.android.internal.policy.impl.showNavigationBar"
            activity.sendBroadcast(intent2)
        } else {
            val intent1 = Intent()
            intent1.action = "com.android.systemui.statusbar.phone.statusclose"
            activity.sendBroadcast(intent1)
            val intent2 = Intent()
            intent2.action = "com.android.internal.policy.impl.hideNavigationBar"
            activity.sendBroadcast(intent2)
        }
    }

}